package LeetCode.NumOffer;

/**
 * @author lumin
 * @date 2022/03/25 10:33
 **/
public class NumOffer05 {
    public String replaceSpace(String s) {
        int sLength = s.length();
        char[] arr = new char[sLength * 3];
        int size = 0;
        for (int i = 0; i < sLength; i++) {
            char c = s.charAt(i);
            if (c == ' ') {
                arr[size++] = '%';
                arr[size++] = '2';
                arr[size++] = '0';
            } else {
                arr[size++] = c;
            }
        }
        String newStr = new String(arr, 0, size);
        return newStr;
    }

}